////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include <windows.h>
#include <stdio.h>
#include <stdlib.h>

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    FILE *TargetHandle = NULL;

    char RootDir[MAX_PATH];
    char CurDir[MAX_PATH];
    char CurFile[MAX_PATH];

    int FolderCount = 0;
    int FileCount = 0;
    int WriteCount = 0;

    strcpy(RootDir, "TestRoot");
    CreateDirectory(RootDir, NULL);

	while(FolderCount < 50)
	{
        printf("Creating folder %d of 50.\r\n", FolderCount);

		sprintf(CurDir, "%s\\Folder_%d", RootDir, FolderCount);
		CreateDirectory(CurDir, NULL);

        FileCount = 0;
		while(FileCount < 50)
		{
            printf("%d%%\r", (FileCount + 1) * 2);

			sprintf(CurFile, "%s\\File_%d.Txt", CurDir, FileCount);
			if((TargetHandle = fopen(CurFile, "wb")) == NULL)
			{
				printf("Could not open '%s' for write.", CurFile);
				return 0;
			}

            WriteCount = 0;
            while(WriteCount < 100)
            {
                fprintf(TargetHandle, "%s : %d\r\n", CurFile, WriteCount);
                WriteCount++;
            }
	        
			fclose(TargetHandle);
            FileCount++;
		}
         printf("\r\n");

        FolderCount++;
	}

	return 0;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

